#图像处理
import cv2

#读图  去噪
# img=cv2.imread('./code.png',cv2.IMREAD_GRAYSCALE)
# print(img)
# #写图
# cv2.imwrite('./code1.png',img)

from PIL import Image,ImageDraw
# 读图 添加水印
im = Image.open('./static/upload/2020-01-25-15-45-24_0.png')
print(im.format,im.size,im.mode)
#生成画笔
draw = ImageDraw.Draw(im)
#绘制
draw.text((1330,740),'1907',fill=(76,234,124,180))
im.show()

#图像压缩
#读图
img = cv2.imread('./static/upload/2020-01-25-15-45-24_0.png')
#压缩 0-9 等级越高越次
# cv2.imwrite('./static/upload/2020-01-25-15-45-24_01.png',img,[cv2.IMWRITE_PNG_COMPRESSION,5])
#jpg  0-100
cv2.imwrite('./static/upload/2020-01-25-15-45-24_03.jpg',img,[cv2.IMWRITE_JPEG_CHROMA_QUALITY,50])
